<?php

namespace app\api\controller\v1;

use app\api\model\Banner;
use app\lib\Exception\BannerGetMissException;
use app\lib\Validate\BannerValidate;

class BannerController extends BaseController
{
    protected $beforeActionList = [];

    public function get($id)
    {
        $id = intval($id);
        (new BannerValidate())->goCheck();
        $banner = Banner::getBannerById($id);
        if(!$banner)
        {
            throw new BannerGetMissException([
                'message' => 'banner 不见了！',
                'code' => 500,
                'error_code' => 10002
            ]);
        }
    
            return json($banner);
    }

}
